define(['jquery', 'bootstrap', 'utilback', 'table', 'form'], function ($, undefined, Utilback, Table, Form) {

    var Controller = {
    	config: {
    		get_url: '/member/read/detail',
    	},
        init: function () {
        	 require(['bootstrap-select', 'bootstrap-select-lang'], function () {
             	$('.selectbox').selectpicker('refresh');
             });
        	Util.api.initSelectOption({
            	target: '[name="locationProvince"]',
            	param: {type: 'PROVINCE'},
            	code: 'codeText',
            	init: function() {
            		
            	}
        	});
        	$('[name="locationProvince"]').on('change', function() {
            	if($(this).val().length > 0) {
            		Util.api.initSelectOption({
                    	target: '[name="locationCity"]',
                    	param: { type:'CITY', parentType: 'PROVINCE', parentCode:$('option[value="'+$(this).val()+'"]').attr('data-value')},
                    	code: 'codeText'
                	});
            	} else {
            		$.each(['City', 'Area'], function(m, t) {
         				$('[name="location' + t + '"]').html('');
            		});
            	}
            });
            $('[name="locationCity"]').on('change', function() {
            	if($(this).val().length > 0) {
            		Util.api.initSelectOption({
                    	target: '[name="locationArea"]',
                    	param: { type:'AREA', parentType: 'CITY', parentCode:$('option[value="'+$(this).val()+'"]').attr('data-value')},
                    	code: 'codeText'
                	});
            	} else {
         			$('[name="locationArea"]').html('');
            	}
            });
            
            $('.btn-cx').on('click', function() {
                var params = $('#search-form').serialize();
            	Util.api.ajax({
            		url: '/member/read/page',
            		type: 'post',
                    data: params,
            		succ: function(ret) {
            			$('.result').text("共" + ret.total + '位');
            		}
            	});
            });
        }
    };
    return Controller;
});